﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TourAgency.Admin.Modify
{
    public partial class EditDestination : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["editDestination"] != null)
                {
                    int editDestionationID = int.Parse(Session["editDestination"].ToString());
                    ToursAgencyDAL.Destination editDest = ToursAgencyDAL.ToursAgencyDataFuncs.GetDestinationByID(editDestionationID);
                    this.textBoxName.Text = editDest.Name;
                }
            }
        }

        protected void buttonSaveDestination_Click(object sender, EventArgs e)
        {
            ToursAgencyDAL.Destination d = new ToursAgencyDAL.Destination();
            int editDestionationID = int.Parse(Session["editDestination"].ToString());
            d.ID = editDestionationID;
            d.Name = this.textBoxName.Text;
            ToursAgencyDAL.ToursAgencyDataFuncs.EditDestination(d);
            Response.Redirect("~/Admin/Destinations.aspx");
        }
    }
}